package com.xhsj.user.generalprocess.web;

import com.xhsj.user.generalprocess.vo.GeneralAuditVo;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.*;
import com.xhsj.user.utils.Message;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;

import org.springframework.web.bind.annotation.RestController;


import com.xhsj.user.generalprocess.service.TbPamGeneralProcessTaskService;
import com.xhsj.user.generalprocess.entity.TbPamGeneralProcessTask;

import javax.validation.Valid;


/**
 * <p>
 * 通用流程任务表 前端控制器
 * </p>
 *
 * @author suxiaolin
 * @since Jan 21, 2021 11:10:35 AM
 */
@Slf4j
@Api(tags = "通用流程任务表")
@RestController
@RequestMapping("/generalprocess/tbPamGeneralProcessTask")
public class TbPamGeneralProcessTaskController {

	@Autowired
    public TbPamGeneralProcessTaskService service;


	/**
	 * 流程启动
	 * @author 苏小林
	 * @date 2021/1/25 10:25
	 * @param: generalAuditVo
	 * @return: com.xhsj.transform.utils.Message
	 */
	/*@RequestMapping(value = "/startProcess",method = RequestMethod.POST)
	public Message startProcess(@RequestBody GeneralAuditVo generalAuditVo) {
        log.info("流程启动参数{}", generalAuditVo);
        // 填充表名参数
        this.fillParams(generalAuditVo);

        generalAuditVo.setUserIds(Arrays.asList(281L));
        try {
            service.startProcess(generalAuditVo,generalCallableVo -> {
                System.err.println("回调:"+generalAuditVo.toString());
            });
            return Message.success();
        } catch (Exception e) {
            log.error("出错:{}",e);
            return Message.error();
        }

    }*/

    /**
     * 流程处理
     * @author 苏小林
     * @date 2021/1/25 10:27
     * @param: generalAuditVo
     */
    @RequestMapping(value = "/startProcess",method = RequestMethod.POST)
    public void handleProcess(@RequestBody GeneralAuditVo generalAuditVo) {

    }

    /**
     * 填充参数
     * @author 苏小林
     * @date 2021/1/22 17:48
     * @param: generalAuditVo
     */
    private void fillParams(GeneralAuditVo generalAuditVo) {
        generalAuditVo.setProcessType("foreign_apply");
        generalAuditVo.setNodeTableName("tb_pam_general_node");
        generalAuditVo.setTaskTableName("tb_pam_general_process_task");
        generalAuditVo.setHiTaskTableName("tb_pam_general_process_hi_task");
        generalAuditVo.setOpinionFileTableName("tb_pam_general_opinion_file");

    }


}

